<div class="container_24">
<ol class=" clearfix">
	<?php
		if (!empty($project)):
	?>

		<li class="clearfix alpha grid_6">
			<div class="project-left grid_6 alpha">
				<div class="l-curve-top">							
					<div class="r-curve-top">
						<div class="top-bg"></div>
					</div>
				</div>
				<div class="shad-bg-lft clearfix">
					<div class="shad-bg-rgt">
						<div class="shad-bg">
								<div class="center clearfix">
										<div class="center-top clearfix">
										<div class="small-description">
											<?php echo $this->Html->link($this->Html->showImage('Project', $project['Attachment'], array('dimension' => 'big_thumb', 'alt' => sprintf(__l('[Image: %s]'), $this->Html->cText($project['Project']['name'], false)), 'title' => $this->Html->cText($project['Project']['name'], false)),array('aspect_ratio'=>1)), array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('target' => '_top', 'escape' => false)); ?>
											<div class="project-head">
											<h3><?php echo $this->Html->link($this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words']),array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false, 'target' => '_top', 'title' => $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words'])));?></h3>
											<p> <?php echo __l('by') . ' '; ?><?php echo $this->Html->link($this->Html->cText($project['User']['username']), array('controller' => 'users', 'action' => 'view', $project['User']['username']), array('target' => '_top', 'escape' => false, 'title' => $this->Html->cText($project['User']['username'], false)));?></p>
											</div>
											<p class="description-content"><?php echo $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['short_description'], false), 200), $project['Project']['detected_suspicious_words']);?></p>
											<p>
												<?php
													$location = array();
													$place = '';
													if (!empty($project['City']['name'])) :
														$location[] = $project['City']['name'];
													endif;
													if (!empty($project['Country']['name'])) :
														$location[] = $project['Country']['name'];
													endif;
													$place = implode(', ', $location);
													if ($place):
														if(!empty($project['Country']['iso2'])):
												?>
													<span class="flags flag-<?php echo strtolower($project['Country']['iso2']); ?>" title ="<?php echo $project['Country']['name']; ?>"><?php echo $project['Country']['name']; ?></span>
												<?php
														endif;
														echo $this->Html->link($place, array('controller' => 'projects', 'action' => 'index', 'city'=>$project['City']['slug']), array('target' => '_top', 'escape' => false));
													endif;
												?>
											</p></div>
											<div class="clearfix">
											<dl class="feature-list grid_5">
												<dt class="comments" title="<?php echo __l('Comments'); ?>"><?php echo __l('Comments:') . ' '; ?></dt>
													<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_comment_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Comments'), array('target' => '_top', 'escape' => false)); ?></dd>
												<dt class="updates" title="<?php echo __l('Updates'); ?>"><?php echo __l('Updates:') . ' '; ?></dt>
													<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['blog_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Updates'), array('target' => '_top', 'escape' => false)); ?></dd>
												<dt class="views" title="<?php echo __l('Views'); ?>"><?php echo __l('Views:') . ' '; ?></dt>
													<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_view_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug']), array('target' => '_top', 'escape' => false)); ?></dd>
											</dl>
											<?php if (Configure::read('Project.is_enable_idea')): ?>
													<div class=" vote-count vote-count-small">
													<div class="js-rating-display grid_right star-rating-view">
														<?php
															$average_rating = (!empty($project['Project']['project_rating_count'])) ? ($project['Project']['total_ratings']/$project['Project']['project_rating_count']) : 0;
															echo $this->element('_star-rating', array('project_id' => $project['Project']['id'], 'current_rating' => $average_rating, 'total_rating' => $project['Project']['total_ratings'],'rating_count' => $project['Project']['project_rating_count'],'canRate' => 0));


														?>
													<ul class="list count-list clearfix">
														<li class="supporters" title="<?php echo __l('Supporters'); ?>"><?php echo $this->Html->cInt($project['Project']['project_rating_count']); ?></li>
														<li class="average" title="<?php echo __l('Average votes'); ?>"><?php echo $this->Html->cFloat($average_rating); ?></li>
													</ul>
													</div>
													</div>
													<?php endif; ?>
											</div>
											<?php $collected_percentage = ($project['Project']['collected_percentage']) ? $project['Project']['collected_percentage'] : 0;?>
										</div>
										<div class="progress-inner clearfix">
											<div class="progress-block clearfix">
												<p class="progress-bar progress-bar-amount" title = '<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>'>
													<span style="width:<?php echo ($collected_percentage > 100) ? '100%' : $collected_percentage.'%'; ?>;" title = "<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>"></span>
												</p>
											</div>
											<div class="clearfix">
												<dl class="deal-value grid_2">
													<?php if($project['Project']['project_status_id'] != ConstProjectStatus::Pending): ?>
														<dt><?php echo __l('funded') ?></dt>
														<dd><?php echo $this->Html->cInt($collected_percentage). __l('%');?></dd>
													<?php endif; ?>
												</dl>
												<dl class="deal-discount grid_2 alpha omega">
													<dt><?php echo __l('pledged') ?></dt>
													<dd><?php echo Configure::read('site.currency') . $this->Html->cCurrency($project['Project']['collected_amount']); ?></dd>
												</dl>
												<dl class="deal-save grid_2 alpha omega">

												<?php if (!empty($project['Project']['project_fund_goal_reached_date']) && $project['Project']['project_fund_goal_reached_date'] != '0000-00-00 00:00:00'): ?>
														<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_fund_goal_reached_date']); ?></dt>
														<dd><?php echo __l('funded'); ?></dd>
												<?php elseif($project['Project']['project_status_id'] == ConstProjectStatus::FundingExpired): ?>
														<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_funding_end_date']); ?></dt>
														<dd><?php echo __l('expired'); ?></dd>
												<?php elseif($project['Project']['project_status_id'] == ConstProjectStatus::ProjectCancelled): ?>
														<dt><?php echo $this->Html->cDateTimeHighlight($project['Project']['project_cancelled_date']); ?></dt>
														<dd><?php echo __l('Cancelled'); ?></dd>
												<?php else: ?>
														<dt><?php echo (round($project[0]['enddate']) >0) ? __l('days to go') : __l('hours to go'); ?></dt>
														<dd>
															<?php
																if ($project['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding || $project['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached || $project['Project']['project_status_id'] == ConstProjectStatus::GoalReached):
																	if(round($project[0]['enddate']) >0):
																		echo $this->Html->cInt($project[0]['enddate']);
																	else:
																	$end_time = intval(strtotime($project['Project']['project_funding_end_date'] . ' 23:59:59') - time()); 			
															?>
																		<div class="time-count">
																			<div class="js-countdown">&nbsp;</div>
																			<span class="js-time hide"><?php echo $this->Html->cInt($end_time,false);?></span>
																		</div>
															<?php
																	endif;
																endif;
															?>
														</dd>
												<?php endif; ?>
											  </dl>
											</div>
										</div>
									</div>
     		<div class="bottom-left">
									<div class="bottom-right">
											<div class="bottom-center"> </div>
									</div>
							</div>
						</div>
					</div>
				</div>
				<div class="l-curve-bot">							
					<div class="r-curve-bot">
						<div class="bot-bg"></div>
					</div>
				</div>
			</div>
		</li>
	<?php
		else:
	?>
		<li class="notice">
			<p><?php  echo __l('No Projects available');?>	</p>
		</li>
	<?php
		endif;
	?>
</ol>
</div>